import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  //让路由跳转的时候，去掉#
  history: createWebHistory(import.meta.env.BASE_URL), // import.meta.env.BASE_URL默认为/
  routes: [
    {
      path: '/login',
      component: () => import('@/views/login/index.vue'),
    },
    {
      path: '/menu',
      component: () => import('@/views/menu/index.vue'),
      redirect: '/menu/homepage',
      children: [
        {
          path: '/menu/personage',
          component: () => import('@/views/menu/personage/index.vue'),
        },
        {
          path: '/menu/contribute',
          component: () => import('@/views/menu/contribute/index.vue'),
        },
        {
          path: '/menu/homepage',
          component: () => import('@/views/menu/homepage/index.vue'),
          redirect: '/menu/homepage/video',
          children: [
            {
              path: '/menu/homepage/video',
              component: () => import('@/views/menu/homepage/video/index.vue'),
            },
            {
              path: '/menu/homepage/like',
              component: () => import('@/views/menu/homepage/like/index.vue'),
            },
          ],
        },
      ],
    },
    {
      path: '/',
      component: () => import('@/views/home/index.vue'),
      redirect: '/home/main',
      children: [
        {
          path: '/home/main',
          component: () => import('@/views/home/main/index.vue'),
        },
        {
          path: '/home/statistics',
          component: () => import('@/views/home/statistics/index.vue'),
        },
        {
          path: '/home/news',
          component: () => import('@/views/home/news/index.vue'),
        },
        {
          path: '/home/history',
          component: () => import('@/views/home/history/index.vue'),
        },
      ],
    },
  ],
})

export default router
